package cn.yhp.mybatis.session;

import cn.yhp.mybatis.builder.xml.XMLConfigBuilder;
import cn.yhp.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;

/**
 * 构建SqlSessionFactory的工厂
 * @author yhp
 * @date 2023/11/18
 */
public class SqlSessionFactoryBuilder {

    /**
     * 测试入口是这个，将xml配置路径传入，在此方法内构建configuration对象传递贯穿整个链路
     * @param reader
     * @return
     */
    public SqlSessionFactory build(Reader reader){
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader);
        return build(xmlConfigBuilder.parse());
    }
    public SqlSessionFactory build(Configuration configuration){
        return new DefaultSqlSessionFactory(configuration);
    }
}
